#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;
using ULL = unsigned long long;

const int p = 131, N = 1e5 + 10;

int n, m;
char str[N];
ULL h[N];
ULL P[N];

ULL get(int l, int r){
    return h[r] - h[l - 1] * P[r - l + 1]; 
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m;
    cin >> str + 1;
    P[0] = 1;
    for(int i = 1; i <= n; i ++){
        h[i] = h[i - 1] * p + str[i];
        P[i] = P[i - 1] * p;
    }



    int l1, r1, l2, r2;
    while(m --){
        cin >> l1 >> r1 >> l2 >> r2;
        
        if(get(l1, r1) == get(l2, r2)){
            cout << get(l1, r1) << " " << get(l2, r2) << endl;
            cout << "YES" << '\n';
        }else{
            cout << "NO\n";
        }
    }


    return 0;
}